package com.inspire.springboot.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementSetter;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Component;

import java.sql.SQLException;
import java.util.List;

@Component
public class JdbcTemplate2 {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    public JdbcTemplate2() {
    }

    public <T> List<T> query(TestInterface3 interface3, String sql, PreparedStatementSetter pss, RowMapper<T> rowMapper) throws DataAccessException {
        try {
            rowMapper.mapRow(null,1);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return this.jdbcTemplate.query(sql, pss, rowMapper);
    }
}
